#encoding:utf-8
'''
Created on 2012/2/27
argv[1]為刪除0之後的data
argv[2]為class的data
argv[3]為最後結合起來的data，形式為A12,A45,...,C4,C8
@author: Netdb_Heng
'''
#參數一為母體，參數二為輸入Label，參數三為輸出sample，參數四為輸出sample的class，參數五為筆數

import sys

print ( "compare:" + sys.argv[1] +  "output to " + sys.argv[2] )

instance_inf = open(sys.argv[1])

outf = open(sys.argv[2],'w')

instance_lines = instance_inf.readlines()

instance=0
same=0


instance_i1 = instance_lines[0].split()
len_i1 = len(instance_i1)
instance_i2 = instance_lines[1].split()
len_i2 = len(instance_i2)

'''if(len_i1>len_i2):
    len_i = len_i1
else:
    len_i = len_i2'''
             
for i in range(len_i1):
    for j in range(len_i2):
        if(int(instance_i1[i].split(":")[0]) == int(instance_i2[j].split(":")[0]) ):
            same+=1
            outf.write(instance_i1[i].split(":")[0] + ":" + instance_i1[i].split(":")[1])
            outf.write("  ,  " + instance_i2[j].split(":")[0] + ":" + instance_i2[j].split(":")[1] + "\n")
outf.write("\n" + "same : " + str(same))                
       
instance_inf.close();
outf.close();

